package com.zhuidian.mothernote.activity;

import android.annotation.SuppressLint;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.base.decoration.LinearLayoutDecoration;
import com.base.listener.ItemClickListener;
import com.base.presenter.BasePresenter;
import com.zhuidian.mothernote.R;
import com.zhuidian.mothernote.adapter.QuestionCommentAdapter;
import com.zhuidian.mothernote.bean.CommentBean;
import com.zhuidian.mothernote.global.BaseActivity;
import com.zhuidian.mothernote.presenter.QuestionCommentPresenter;

import java.util.ArrayList;
import java.util.List;

public class QuestionCommentActivity extends BaseActivity<QuestionCommentPresenter> {
    private RelativeLayout ll_title;
    private ImageView iv_arrow;
    private ImageView iv_collect;
    private ImageView iv_share;
    private LinearLayout ll_bottom;
    private LinearLayout ll_note;
    private LinearLayout ll_check_other_answer;
    private ImageView iv_headimage;
    private TextView tv_name;
    private ImageView iv_follow;
    private TextView tv_content;
    private TextView tv_read_volume;
    private TextView tv_report;
    private TextView tv_all_comment;
    private QuestionCommentPresenter questionDetailPresenter;
    private QuestionCommentAdapter adapter;

    @Override
    protected int inflateMainLayoutId() {
        return R.layout.activity_question_comment;
    }

    @SuppressLint("WrongConstant")
    @Override
    protected void initView(View view) {

        ll_title = (RelativeLayout) view.findViewById(R.id.ll_title);
        iv_arrow = (ImageView) view.findViewById(R.id.iv_arrow);
        iv_collect = (ImageView) view.findViewById(R.id.iv_collect);
        iv_share = (ImageView) view.findViewById(R.id.iv_share);
        ll_bottom = (LinearLayout) view.findViewById(R.id.ll_bottom);

        RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
        recyclerView.setHasFixedSize(true);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(linearLayoutManager);
        recyclerView.addItemDecoration(new LinearLayoutDecoration(context,0));
        adapter = new QuestionCommentAdapter(context);
        View headerView = adapter.inflateHeaderView(R.layout.head_question_comment);
        ll_note = (LinearLayout) view.findViewById(R.id.ll_note);
        ll_check_other_answer = (LinearLayout) headerView.findViewById(R.id.ll_check_other_answer);
        iv_headimage = (ImageView) headerView.findViewById(R.id.iv_headimage);
        tv_name = (TextView) headerView.findViewById(R.id.tv_name);
        iv_follow = (ImageView) headerView.findViewById(R.id.iv_follow);
        tv_content = (TextView) headerView.findViewById(R.id.tv_content);
        tv_read_volume = (TextView) headerView.findViewById(R.id.tv_read_volume);
        tv_report = (TextView) headerView.findViewById(R.id.tv_report);
        tv_all_comment = (TextView) headerView.findViewById(R.id.tv_all_comment);
        adapter.setOnClickListener(this);
        adapter.setItemClickListener(new ItemClickListener() {
            @Override
            public void onItemClick(View view, int position) {

            }
        });
        recyclerView.setAdapter(adapter);
    }


    @Override
    protected void setListener() {
        iv_arrow.setOnClickListener(this);
        iv_collect.setOnClickListener(this);
        iv_share.setOnClickListener(this);
        ll_check_other_answer.setOnClickListener(this);
        iv_follow.setOnClickListener(this);
        tv_read_volume.setOnClickListener(this);
        tv_report.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        super.onClick(view);

        switch (view.getId()) {
            case R.id.iv_arrow:
                        onBackPressed();
                break;
        }
    }

    @Override
    protected BasePresenter getPresenter() {
        setTopGone();
        questionDetailPresenter = new QuestionCommentPresenter();
        List<CommentBean> demoList = new ArrayList<CommentBean>();
        for (int index = 0; index <20 ; index++) {
            CommentBean questionBean = new CommentBean();
            questionBean.setName("我是名字");
            questionBean.setComment("我是内容我是");
            questionBean.setTime("17:00");
            questionBean.setLike("4个回复");
            demoList.add(questionBean);
        }
        adapter.setList(demoList);
        return questionDetailPresenter;
    }
}
